<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="${staticServer}/inc/style/main.css"/>
    <link rel="stylesheet" href="${staticServer}/inc/style/page.css"/>
    <link rel="stylesheet" href="${staticServer}/css/struct_info.css"/>
    <script src="${staticServer}/inc/js/jquery.js"></script>
    <script src="${staticServer}/inc/js/pageset.js"></script>
    <script src="${staticServer}/inc/js/submitter.js"></script>
    <script src="${staticServer}/inc/js/infopad.js?2.2"></script>
    <script type="text/javascript" src="${staticServer}/common/uploadify/jquery.uploadify.js"></script>
    <script type="text/javascript" src="${staticServer}/js/web/uploadImg.js?1.5"></script>

    <link rel="stylesheet" href="${staticServer}/inc/style/date/datepicker.css"/>
    <script src="${staticServer}/inc/js/datepicker.js"></script>

    <style>
        #SWFUpload_0 {
            margin-top: 70px;
            margin-left: -30px;
        }
    </style>
    <script>
        var contextPath = '${contextPath}';
        var _contextPath = '${staticServer}';

        $(function () {
            $("#type").val("<#if goods??>${goods.type}</#if>");
            $("#center_id").val("<#if goods??>${goods.region}</#if>");
            $("#purpose").val("<#if goods??>${goods.purpose}</#if>");
            $("#state").val("<#if goods??>${goods.state}</#if>");
            $("#apply_status").val("<#if goods??>${goods.apply_status}</#if>");
            $("#pratin").val("<#if goods??>${goods.good_muns_id}</#if>");
            
             var good_mnus = '<#if goods??>${goods.good_pard_id}</#if>';
             
            $.post("${contextPath}/goods/goodsMnus.json", {
     	    	"good_mnus" : good_mnus
     		}, function(ms) {
     	    	var list = ms.list;
     	    	var objHtml="";
     	    	$("#student").val("");
     	    	for(var i=0;i<list.length;i++){
     	    		objHtml +='<option value="'+list[i].id+'">'+list[i].name+'</option>';
     	    	}
     	    	$("#pratin").html(objHtml);
     	    });
		if(good_mnus==1){
			$("#dnxh").show();
			$("#bh").show();
			$("#fey").hide();
			$("#kdxh").hide();
			$("#contz").show();
			$("#nummone").show();
			$("#numb").show();
		}else if(good_mnus==2){
			$("#kdxh").show();
			$("#fey").show();
			$("#dnxh").hide();
			$("#bh").hide();
			$("#contz").show();
			$("#nummone").hide();
			$("#numb").hide();
		}else if(good_mnus==3){
			$("#cglink").show();
			$("#dnxh").hide();
			$("#bh").hide();
			$("#fey").hide();
			$("#kdxh").hide();
			$("#contz").show();
			$("#nummone").show();
			$("#numb").show();
		}else{
			$("#dnxh").hide();
			$("#bh").hide();
			$("#fey").hide();
			$("#kdxh").hide();
			$("#cglink").hide();
			$("#contz").show();
			$("#nummone").show();
			$("#numb").show();
		}  
      });
        
        var toEdit = function (id) {
			var goodsId=id;
			var goods_child_id = $("#goods_child_id").val(); //物品子Id
			$.post("${contextPath}/goods/getGoodsNewsById.json", {
		    	"goodsId" : goodsId,
		    	"goods_child_id" : goods_child_id
			}, function(ms) {
		    	var goodsNews = ms.goodsNews;
		    	$("#goodid").val(goodsId);
		    	$("#center_id").val(goodsNews.region);
		    	$("#good_mnus").val(goodsNews.good_pard_id);
		    	$("#pratin").val(goodsNews.good_muns_id);
		    	$("#itemName").val(goodsNews.item_name);
		    	$("#model").val(goodsNews.model);
		    	$("#code").val(goodsNews.code);
		    	$("#broadband_type").val(goodsNews.broadband_type);
		    	$("#supplier").val(goodsNews.supplier);
		    	$("#number").val(goodsNews.number);
		    	$("#unitPrice").val(goodsNews.unit_price);
		    	$("#totalCalculation").val(goodsNews.total_calculation);
		    	$("#squser").val(goodsNews.sq_user);
		    	$("#purchasing_num").val(goodsNews.purchasing_num);
		    	$("#purchasing_link").val(goodsNews.purchasing_link);
		    	$("#msg").val(goodsNews.msg);
		    	
		    	if(goodsNews.good_pard_id==1){
					$("#dnxh").show();
					$("#bh").show();
					$("#fey").hide();
					$("#kdxh").hide();
					$("#contz").show();
					$("#contz1").show();
					$("#nummone").show();
					$("#numb").show();
				}else if(goodsNews.good_pard_id==2){
					$("#kdxh").show();
					$("#fey").show();
					$("#dnxh").hide();
					$("#bh").hide();
					$("#contz").show();
					$("#contz1").show();
					$("#nummone").hide();
					$("#numb").hide();
				}else if(goodsNews.good_pard_id==3){
					$("#cglink").show();
					$("#dnxh").hide();
					$("#bh").hide();
					$("#fey").hide();
					$("#kdxh").hide();
					$("#contz").show();
					$("#contz1").show();
					$("#nummone").show();
					$("#numb").show();
				}else{
					$("#dnxh").hide();
					$("#bh").hide();
					$("#fey").hide();
					$("#kdxh").hide();
					$("#cglink").hide();
					$("#contz").show();
					$("#contz1").show();
					$("#nummone").show();
					$("#numb").show();
				}  
		    });
			
		}     
    </script>
  
    <script>
        function save() {
        	var id=$("#id").val();
            var auditStatus =$("#apply_status").val();
            var all_words =$("#all_words").val();
           $.post("${contextPath}/goods/ajaxAudit.json", {
                "id": id,
                "all_words": all_words,
                "auditStatus": auditStatus
                },function (ms) {
	                var msg = ms.msg;
	                if (msg != null && msg == "1") {
	                	infopad.msg("操作成功！");
	                    window.location.href = "${contextPath}/goods/myGoodsList.htm";
	                } else {
	                	infopad.err("操作失败!");
	                }
            	});
        }
    </script>
</head>
<input type="hidden" id="id" value="<#if goods??>${goods.id}</#if>">
<body>
<div id="home_link">
    <ul>
        <li></li>
        <li>&gt;</li>
        <li>采购管理</li>
        <li>&gt;</li>
        <li class="current">采购审核</li>
    </ul>
</div>

<div id="container">
    <div id="title">采购审核</div>
    <table id="tbl_State">
		<tbody align="right">
			<tr>
				<td width="5%">物品名称</td>
				<td width="5%">物品种类</td>
				<td width="5%">型号</td>
				<td width="5%">数量</td>
				<td width="5%">创建时间</td>
				<td width="5%">最新编辑人</td>
				<td width="5%">操作</td>
			</tr>
			<#if goodsNewList??>
		              <#list goodsNewList as list>
						<tr align="right">
							<td width="8%" >${list.item_name}</td>
		                   <td width="10%" >
		                   ${list.good_parint_name} - ${list.goods_name}
		                    </td>
							<td  width="8%">
								${list.model}
							</td>
		                   	<td  width="5%" >
		                    	${list.number}
		                    </td>
		                    <td  width="15%" >
		                    	${list.create_time}
		                    </td>
		                    <td  width="10%">
		                     	${list.sq_user}
		                    </td>
		                    <td width="10%" align="right">
		                    	<button class="btn_highlight" onclick="toEdit('${list.id}')">查看</button>
		                    </td>
						</tr>	
		               </#list>
	             </#if>
		</tbody>
	</table>
    <table id="infotable">
    	<tr>
            <th>类型:</th>
            <td>
                <select id="type" disabled="disabled">
                    <option value="1">固定资产</option>
                    <option value="2">消耗品</option>
                </select>
            </td>
        </tr>

        <tr>
            <th>办公地址:</th>
            <td>
                <select id="center_id" disabled="disabled">
                <#if offList??>
                    <#list offList as list>
                        <option value="${list.keyname}">${list.name}</option>
                    </#list>
                </#if>
                </select>
            </td>
        </tr>

        <tr>
            <th>物品分类:</th>
            <td >
                <select id="good_mnus" disabled="disabled">
                <#if list??>
                    <#list list as list>
                        <option value="${list.id}">${list.name}</option>
                    </#list>
                </#if>
                </select>
                 <select id="pratin" disabled="disabled">
                        <option value="">请选择</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>物品名称:</th>
            <td><input id="itemName" type="text" size="50" maxlength="30" disabled="disabled" value="${goods.item_name}"/></td>
        </tr>
        <tr id="dnxh" style="display:none">
            <th >型号:</th>
            <td><input id="model" type="text" size="50" maxlength="30" disabled="disabled" value="${goods.model}"/></td>
        </tr>
        <tr  id="bh" style="display:none">
            <th>编号/编码:</th>
            <td><input id="code" type="text" size="50" maxlength="30" disabled="disabled" value="${goods.code}"/></td>
        </tr>
        <tr id="kdxh" style="display:none">
            <th >类型:</th>
            <td><input id="broadband_type" type="text" size="50" maxlength="30" placeholder="例：联通-20M-光纤/联通卡、移动卡" disabled="disabled" value="${goods.broadband_type}"/></td>
        </tr>
        <tr  id="fey" style="display:none">
            <th>费用:</th>
            <td><input id="supplier" type="text" size="50" maxlength="30" value="${goods.supplier}" disabled="disabled"/></td>
        </tr>
        <tr id="numb">
            <th>物品数量:</th>
            <td><input id="number" value="1" onchange="totalCalculation()"
                       onkeyup="this.value=this.value.replace(/[^0-9]/g,'')"
                       onafterpaste="this.value=this.value.replace(/[^0-9]/g,'')" type="text" size="50" maxlength="30" value="${goods.model}" disabled="disabled"/>
            </td>
        </tr>

        <tr id="nummone">
            <th>物品单价:</th>
            <td><input id="unitPrice" type="text" onchange="totalCalculation()" onkeyup="clearNoNum(this)" size="50"
                       maxlength="30" value="${goods.unit_Price}" disabled="disabled"/></td>
        </tr>
        <tr id="contz">
            <th>物品单个总额:</th>
            <td><input id="totalCalculation" disabled='disabled' type="text" size="50" maxlength="30" value="${goods.total_Calculation}"/></td>
        </tr>
        <tr id="contz1">
            <th>物品所有总额:</th>
            <td><input id="goods_price_total" disabled='disabled' type="text" size="50" maxlength="30" value="${goods.goods_price_total}"/></td>
        </tr>
        <tr>
            <th>物品申请人:</th>
            <td><input id="squser" type="text"  value="${goods.sq_user}" size="50" maxlength="30" disabled="disabled"/></td>
        </tr>
        <tr>
            <th>采购单号:</th>
            <td><input id="purchasing_num" type="text" value="${goods.purchasing_num}" size="50" maxlength="30" disabled="disabled"/></td>
        </tr>
        <tr>
            <th >采购链接:</th>
            <td><input id="purchasing_link" type="text" size="50" maxlength="50" value="${goods.purchasing_link}" disabled="disabled"/></td>
        </tr>
        
        <tr>
				<th>物品相关图片:</th>
				<td>
					<ul class="imglist">
					<div id="images" style="float: left;">
						<#if img_url?? && img_url!="">
							<#list img_url?split(",") as imgurl>
								<#if imgurl_index !=0>
								<img rel="800:485" width="180" height="109.125" src="http://120.55.241.58/${imgurl}">
								</#if>
							</#list>
						</#if>
					</div>
				<#if webutil.getCookieUser().username=="tanwenjuan"&&goods.apply_status=="2"> 	
					<a class="file_box" style="list-style-type: none;float: left;display: block; width:180px; height:180px; overflow: hidden; border: 1px solid #EBEBEB; background: none repeat scroll 0 0 #F3F3F3; color: #999999; cursor: pointer; text-align: center; margin-left:10px; ">
                    <em style="background:url(${staticServer}/img/add_newpic.png) 0 0; display: inline-block; width:180px; height:180px; overflow: hidden;line-height: 20em; vertical-align: middle;">
                    <input type="file" id="upload" style="display: block;width:180px; height:180px;opacity: 0; filter:alpha(opacity=0); "></em>
                    </a>
                    <label class="zt_widthlabel" style=" font-size:9px; float:left; visibility:hidden;">文件：</label>
                    <input type="text" id="all_words" style=" width:100px; height:10px; float:left;visibility:hidden;" class="input w180" value="<#if goods??>${goods.img_url}</#if>">
				</#if>	
					</ul>
				</td>
			</tr>
        <tr>
            <th>备注:</th>
            <td>
                <textarea id="msg" style="width:400px;height: 150px;" placeholder="如采购物品为特殊物品请在备注表明">${goods.msg}</textarea>
            </td>
        </tr>
       	<tr>
            <th>审核状态:</th>
            <td>
                 <select id="apply_status" <#if flag=="see">disabled</#if>>
                        <option value="">请选择</option>
                        <option value="1">未审核</option>
                        <option value="2">审核通过</option>
                </select>
            </td>
        </tr>
    </table>
		<div style="padding:20px 0 20px 115px;">
		<#if webutil.getCookieUser().username=="tanwenjuan"&&goods.apply_status=="2">
			<input type="button" class="submit" onclick="save();" value="  确定  "/>
		<#elseif flag!="see">
			<input type="button" class="submit" onclick="save();" value="  确定  "/>
		</#if>
			<input type="button" class="btn_normal" onclick="javascript:history.back(-1);" value="  返回列表 "/>
		</div>
</div>

</body>
</html>